package com.example.bookmanagementsystem.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;

@Data
public class BookInfo {
    //图书ID
    private Integer id;
    //书名
    private String bookName;
    //作者名
    private String author;
    //数量
    private Integer count;
    //定价
    //前端展示精度,返回的是一个字符串,前端会全部进行展示
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private BigDecimal price;
    //出版社
    private String publish;
    //状态 0-无效 1-允许借阅 2-不允许借阅
    private Integer status;
    //上面的状态是数字,这里是根据数字而对应的中文是什么,用来进行页面的显示
    private static final HashMap<Integer, String> statusMap = new HashMap<>();

    static {
        statusMap.put(0, "无效");
        statusMap.put(1, "允许借阅");
        statusMap.put(2, "不允许借阅");
    }

    private String statusCN;

    //创建时间
    private Date createTime;
    //更新时间
    private Date updateTime;

    public BookInfo() {
    }

    public HashMap<Integer, String> getStatusMap() {
        return statusMap;
    }

    public BookInfo(Integer id, String bookName, String author, Integer count, BigDecimal price, String publish, Integer status, String statusCN, Date createTime, Date updateTime) {
        this.id = id;
        this.bookName = bookName;
        this.author = author;
        this.count = count;
        this.price = price;
        this.publish = publish;
        this.status = status;
        this.statusCN = statusCN;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }
}
